package thread;

public class Demo19 {

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{

            for(int i = 0; i < 3 ; i++){
                System.out.println("这是t线程");

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t线程结束");
        });

        t.start();
        System.out.println("主线程开始等待");
        //main线程开始等待 t线程
        try {
            t.join();
        }catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("主线程等待结束");

    }
}
